/*var math = require("math");
console.log(math.add(10,10));

var str = "你好";
var buf = Buffer.from(str);
console.log(buf);
console.log(buf.length);
console.log(buf.length);


var buf = Buffer.alloc(10);
buf[0] = 0xaa;
buf[1] = 12;
buf[2] = 255;
console.log(buf);

var buf1 = Buffer.allocUnsafe(10);
console.log(buf1);
*/


/*//引入
var fs = require("fs");
//打开文件
var fd = fs.openSync("hello.txt","w");
//console.log(fd); //返回3，证明打开成功

fs.writeSync(fd,"今天周五",3);
fs.close(fd);
*/


//异步引入
var fs = require("fs");
fs.open("info.txt","w",function(err,fd){
	console.log(err);
	if(!err){
		fs.write(fd,"今天好4开心",function(err,fd){
			if(!err){
				console.log("写入成功");
				fs.close(fd);
			}else{
				console.log("写入失败");
				fs.close(fd);
			}
		});
	}else{
		console.log(fd);
	}
});

console.log("这是异步操作");
